package com.eascs.web.o2o.scheduler.task;

import com.eascs.app.log.Logger;
import com.eascs.app.log.LoggerFactory;
import com.eascs.common.util.StopWatch;
import com.eascs.web.o2o.scheduler.service.*;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import javax.inject.Inject;

/**
 * @author user
 * @version V1.0 TODO(定时同步) 2017年1月5日 下午1:53:44
 */
@Component("reportTask")
public class ReportTask {
	
	protected final Logger logger = LoggerFactory.getLogger(getClass());
	@Inject
	DataCenterService dataCenterService;
	@Inject
	CustomerShopInfoService customerShopInfoService;
	@Autowired
	DayReportService dayService;
	
	
	@Inject
	SynoInfoAssetStructureService synoInfoAssetStructureService;
	
	/*@Scheduled(cron = "0 00 6 * * ?")
	public void saveCustomerShopInfo() {
		logger.info("门店信息同步任务开始......");
		StopWatch stopWatch = new StopWatch();
		customerShopInfoService.saveCustomerShopInfo();
		logger.info("门店信息数据同步任务结束，共耗时：[{}]秒", stopWatch.elapsedTime() / 1000);
	}*/

	/*
	 * 日报表中的业务进度报表的数据同步
	 */
	@Scheduled(cron = "0 00 6 * * ?")
	public void bankAndprocess() {
		StopWatch stopWatch = new StopWatch();
		logger.info("管理层日报一期-业务进度日报表 同步任务开始......");
		dayService.saveReportLoanIngFromService();
		logger.info("管理层日报一期-业务进度日报表 同步任务结束，共耗时：[{}]秒", stopWatch.elapsedTime() / 1000);
		//保存 O2O金融业务台账——投放量统计表（按平台)数据
		//dataCenterService.saveReportPingtaiDelivery();
	}
	
	/*
	 * 日报表中的资产结构报表的数据同步
	 */
	@Scheduled(cron = "0 30 6 * * ?")
	public void AssetStructure() {
		StopWatch stopWatch = new StopWatch();
		logger.info("管理层日报一期-资产结构日报表 同步任务开始......");
		try {
			synoInfoAssetStructureService.saveAssetStructurePrincipalDaily();
		} catch (Exception e) {
			logger.error("管理层日报一期-资产结构日报表异常[{}]",e.getMessage());
		}
		logger.info("管理层日报一期-资产结构日报表 同步任务结束，共耗时：[{}]秒", stopWatch.elapsedTime() / 1000);
	}
	

	/**
	 * 省区流程监控表数据
	 */
	@Scheduled(cron = "0 10 7 * * ?")
	public void processMonitorReport() {
		StopWatch stopWatch = new StopWatch();
		dataCenterService.processMonitorReport();
		logger.info("省区流程监控表数据入库任务结束，共耗时：[{}]秒", stopWatch.elapsedTime() / 1000);
	}


}
